package com.boss.schedule;

import com.boss.salary.service.ISalaryBankPayBackService;
import net.javacrumbs.shedlock.core.SchedulerLock;
import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableScheduling // 通过@EnableScheduling注解开启对计划任务的支持
@EnableSchedulerLock(defaultLockAtMostFor = "PT30S", defaultLockAtLeastFor = "PT10S")
public class Push2PaySchedule {

    @Autowired
    private ISalaryBankPayBackService service;
    private static final String LOCK_KEY = "myScheduledTaskLock";

    private static Logger logger = LoggerFactory.getLogger(Push2PaySchedule.class);
    @Scheduled(cron = "0 5/10 * * * ?")
    @SchedulerLock(name = LOCK_KEY)
    public void push2Pay() {
            // TODO: 10分钟推送一次
            logger.info("数据回流定时任务启动");
            service.pushToPay();
        }

}
